home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=haluto Title=Amazon.de (Image Only) Description=Amazon.de picture import (large picture O N L Y) Site=http://www.amazon.de Language=DE Version=19.02.2005 Requires=3.5.0 Comments=haluto@web.de|Based on Grasmo's Superscript and| - IMDB script| - OMDb/IMDB script| - Amazon (US & DE) script|don't forget the credits of the original scripts - they did most of the work! License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] ***************************************************) program AmazonPictureImport_DE; const //Set this to False if you wish to pick the Amazon Picture manual (german or english) AutomaticAmazonPicPick = FALSE; //Set this to False if you wish the script not automize everything TotalAutomatic = FALSE; var MovieName, Amazon_num: string; TheMovieTitle: string; TheMovieAddress: string; OMDb_link: string; function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer; var i: Integer; begin result := -1; if StartAt < 0 then StartAt := 0; for i := StartAt to List.Count-1 do if Pos(Pattern, List.GetString(i)) <> 0 then begin result := i; Break; end; end; function GetToken(aString, SepChar: String; TokenNum: Integer):String; var Token : string; StrLen : Integer; TNum : Integer; TEnd : Integer; begin StrLen := Length(aString); TNum := 1; TEnd := StrLen; while ((TNum <= TokenNum) and (TEnd <> 0)) do begin TEnd := Pos(SepChar,aString); if TEnd <> 0 then begin Token := Copy(aString,1,TEnd-1); Delete(aString,1,TEnd); TNum := TNum + 1; end else Token := aString; end; if TNum >= TokenNum then GetToken := Token else GetToken := ''; end; function AsinParse(Line : string): string; begin Result := GetToken(GetToken(Line,'.',2),Chr(34),1); end; procedure GetAmazonPic; var LineNr, I: Integer; AmazonPage, AmazonPageNOHTML: TStringList; AmazonPage2, AmazonPageNOHTML2: TStringList; TempHold, TempHold2, THolder: string; FoundSomething: integer; mov, dlink: string; TheLink: string; begin dlink := ''; TheLink := ''; mov := GetField(fieldTranslatedTitle); if mov = '' then begin mov := GetField(fieldOriginalTitle); if mov = '' then mov := MovieName; end; FoundSomething := 1; AmazonPage := TStringList.Create; AmazonPage.Text := GetPage('http://www.amazon.de/exec/obidos/search-handle-url/index=dvd-de&field-title=' + StringReplace(UrlEncode(mov),'+', '%20')); PickTreeClear; if FindLine('Infos zu diesem Titel',AmazonPage,1) <> -1 then begin PickTreeAdd('Amazon(DE) Pictures fⁿr [' + mov + ']',''); LineNr := FindLine('<input type="hidden" name="asin.',AmazonPage,1); dlink := 'http://images-eu.amazon.com/images/P/' + AsinParse(AmazonPage.Getstring(LineNr)) + '.03.LZZZZZZZ.jpg'; PickTreeAdd(mov, dlink); end; if FindLine('Wir haben keine genauen Treffer fⁿr Ihre Suche fⁿr ',AmazonPage,1) <> -1 then FoundSomething := 0; if (FindLine('Die besten Treffer',AmazonPage,1) <> -1) OR (FindLine('Alle Ergebnisse fⁿr',AmazonPage,1) <> -1) then begin I := 1; PickTreeAdd('Amazon(DE) Pictures fⁿr [' + mov + ']',''); while (i <= AmazonPage.Count-1) do begin THolder := AmazonPage.GetString(i); HTMLRemoveTags(THolder); if (Pos('/exec/obidos/ASIN/',AmazonPage.GetString(i)) <> 0) and (THolder <> '') and (Pos('Preis: EUR',AmazonPage.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage.GetString(i)) = 0) then PickTreeAdd(THolder,'http://images-eu.amazon.com/images/P/' + GetToken(AmazonPage.GetString(i),'/',5) + '.03.LZZZZZZZ.jpg'); if THolder = mov then dlink := 'http://images-eu.amazon.com/images/P/' + GetToken(AmazonPage.GetString(i),'/',5) + '.03.LZZZZZZZ.jpg'; i := i + 1; end end; If AutomaticAmazonPicPick and (dlink <> '') then begin GetPicture(dlink); exit; end; mov := GetField(fieldOriginalTitle); if mov = '' then begin mov := GetField(fieldTranslatedTitle); if mov = '' then mov := MovieName; end; AmazonPage2 := TStringList.Create; AmazonPage2.Text := GetPage('http://www.amazon.com/exec/obidos/search-handle-url/index=dvd&field-title=' + StringReplace(UrlEncode(GetField(fieldOriginalTitle)),'+', '%20')); AmazonPageNOHTML2 := TStringList.Create; AmazonPageNOHTML2.Text := AmazonPage2.Text; TempHold2 := AmazonPageNOHTML2.Text; HTMLRemoveTags(TempHold2); AmazonPageNOHTML2.Text := TempHold2; if FindLine('Amazon.com: DVD:',AmazonPage2,1) <> -1 then begin LineNr := FindLine('<input type="hidden" name="asin.',AmazonPage2,1); if FoundSomething = 0 then begin GetPicture('http://images.amazon.com/images/P/' + AsinParse(AmazonPage2.Getstring(LineNr)) + '.01.LZZZZZZZ.jpg'); exit; end else begin PickTreeAdd('Amazon(US) Pictures fⁿr [' + mov + ']',''); PickTreeAdd(mov, 'http://images.amazon.com/images/P/' + AsinParse(AmazonPage2.Getstring(LineNr)) + '.01.LZZZZZZZ.jpg'); end; end; if FindLine('DVD Search Results: we were unable to find exact matches for your search for',AmazonPage,1) <> -1 then if FoundSomething = 0 then exit; if (FindLine('Below are results for',AmazonPage2,1) <> -1) OR (FindLine('All results',AmazonPage2,1) <> -1) OR (FindLine('Most popular results for',AmazonPage2,1) <> -1) then begin I := 1; PickTreeAdd('Amazon(US) Pictures fⁿr [' + mov + ']',''); while (i <= AmazonPage2.Count-1) do begin THolder := AmazonPage2.GetString(i); HTMLRemoveTags(THolder); if (Pos('/exec/obidos/ASIN/',AmazonPage2.GetString(i)) <> 0) and (THolder <> '') and (Pos('Buy new',AmazonPage2.GetString(i)) = 0) and (Pos('Used & new from',AmazonPage2.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage2.GetString(i)) = 0) then begin PickTreeAdd(THolder,'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',5)+ + '.01.LZZZZZZZ.jpg'); if THolder = mov then dlink := 'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',5)+ + '.01.LZZZZZZZ.jpg'; end; if (Pos('/exec/obidos/tg/detail/',AmazonPage2.GetString(i)) <> 0) and (THolder <> '') and (Pos('Buy new',AmazonPage2.GetString(i)) = 0) and (Pos('Used & new from',AmazonPage2.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage2.GetString(i)) = 0) and (Pos('http://www.amazon.com',AmazonPage.GetString(i)) = 0) and (Pos('In-store Pickup',AmazonPage.GetString(i)) = 0) then begin PickTreeAdd(THolder,'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',7)+ + '.01.LZZZZZZZ.jpg'); if THolder = mov then dlink := 'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',7)+ + '.01.LZZZZZZZ.jpg'; end; i := i + 1; end end If AutomaticAmazonPicPick and (dlink <> '') then begin GetPicture(dlink); exit; end; if TotalAutomatic and (dlink <> '') then GetPicture(dlink) else if PickTreeExec(THolder) then GetPicture(THolder); end; begin if CheckVersion(3,5,0) then begin OMDb_link := ''; TheMovieTitle:=''; TheMovieAddress:=''; MovieName := GetField(fieldTranslatedTitle); if MovieName = '' then begin MovieName := GetField(fieldOriginalTitle); if MovieName = '' then Input('Movie Title', 'Bitte Titel eingeben :', MovieName); end; GetAmazonPic; //DisplayResults; end else ShowMessage('Dieses Script ben÷tigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)'); end.